import {
    createApp
} from 'vue'
import App from './App.vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import router from './router'
import {
    createPinia
} from "pinia"
import "./assets/css/init.css"
import "./assets/QWeather-Icons-1.3.1/font/qweather-icons.css"
const pinia = createPinia()

createApp(App)
    .use(router)
    .use(pinia)
    .use(ElementPlus)
    .mount('#app')

//禁止客户端随意缩放
var t = window.devicePixelRatio
document.body.style.zoom = 1 / t

document.addEventListener('keydown', function (event) {
    if ((event.ctrlKey === true || event.metaKey === true) &&
        (event.which === 61 || event.which === 107 || event.which === 173 || event.which === 109 ||
            event.which === 187 || event.which === 189)) {
        event.preventDefault()
    }
}, false)

// Chrome IE 360
window.addEventListener('mousewheel', function (event) {
    if (event.ctrlKey === true || event.metaKey) {
        event.preventDefault()
    }
}, {
    passive: false
})

window.addEventListener('DOMMouseScroll', function (event) {
    if (event.ctrlKey === true || event.metaKey) {
        event.preventDefault()
    }
}, {
    passive: false
})

//rem自适应函数
window.onload = function () {
    function setHtml() {
        let cWidth =
            document.body.clientWidth || document.documentElement.clientWidth;
        let target = cWidth / 19.2;
        document.documentElement.style.fontSize = target + "px";
    }
    setHtml();
    window.onresize = setHtml;
}

//禁止客户端修改storage里面的数据
window.addEventListener("storage", (e) => {
    localStorage.setItem(e.key, e.oldValue)
})